package com.neutech.service.impl;

import com.neutech.mapper.RegisterMapper;
import com.neutech.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Service
public class RegisterServiceImpl implements RegisterService {
    @Autowired
    private RegisterMapper registerMapper;
    @Override
    public List<Map<String, Object>> queryRegister() {
         return  registerMapper.queryRegisterList();

    }

    @Override
    public List<Map<String, Object>> queryNotRegister(String doctor) {
       String ss="未诊";
       return registerMapper.queryRegisterBystate(ss,doctor);
    }

    @Override
    public List<Map<String, Object>> queryAlRegister(String doctor) {
        String ss="已诊";
        return registerMapper.queryRegisterBystate(ss,doctor);
    }

    @Override
    public void addRegister(Map<String,Object> map) {
        for (Object key : map.keySet()) {
            Object  value = map.get(key);
            map.put((String) key,value);
        }
        map.put("state","未诊");
        registerMapper.addRegister(map);

    }

    @Override
    public void delRegister(Integer num) {
        registerMapper.delRegisterByNum(num);
    }



    @Override
    public List<Map<String, Object>> queryIdRegister(Integer idnumber) {
       return registerMapper.queryRegisterByIdnumber(idnumber);
    }

    @Override
    public void updateRegisterByIdnumber(Integer idnumber) {
        Map<String,Object> map =registerMapper.queryRegisterByIdnumber(idnumber).get(0);
        map.put("state","已诊");
         registerMapper.updateRegisterByIdnumber(map);
    }
}
